home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Graphics Programming (2nd Edition) / Visual Basic Graphics Programming 2nd Edition.iso / OldSrc / CH3 / SRC / TOGRAY.BAS < prev    next >
BASIC Source File  |  1996-01-24  |  2KB  |  35 lines

  1. Attribute VB_Name = "ToGray"
  2. Option Explicit
  3.  
  4. Type PALETTEENTRY
  5.     peRed As Byte
  6.     peGreen As Byte
  7.     peBlue As Byte
  8.     peFlags As Byte
  9. End Type
  10. Public Const PC_EXPLICIT = &H2      ' Match to system palette index.
  11. Public Const PC_NOCOLLAPSE = &H4    ' Do not match color existing entries.
  12.  
  13. ' GetDeviceCaps constants.
  14. Global Const RASTERCAPS = 38    ' Raster device capabilities.
  15. Global Const RC_PALETTE = &H100 ' Has palettes.
  16. Global Const NUMRESERVED = 106  ' # reserved entries in palette.
  17. Global Const SIZEPALETTE = 104  ' Size of system palette.
  18.  
  19. #If Win32 Then  ' 32-bit VB.
  20.     Declare Function GetDeviceCaps Lib "GDI32" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  21.     Declare Function ResizePalette Lib "GDI32" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  22.     Declare Function SetPaletteEntries Lib "GDI32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  23.     Declare Function GetPaletteEntries Lib "GDI32" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  24.     Declare Function GetSystemPaletteEntries Lib "GDI32" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  25.     Declare Function RealizePalette Lib "GDI32" (ByVal hdc As Long) As Long
  26. #Else           ' 16-bit VB.
  27.     Declare Function GetDeviceCaps Lib "GDI" (ByVal hdc As Integer, ByVal nIndex As Integer) As Integer
  28.     Declare Function ResizePalette Lib "GDI" (ByVal hPalette As Integer, ByVal nNumEntries As Integer) As Integer
  29.     Declare Function SetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  30.     Declare Function GetPaletteEntries Lib "GDI" (ByVal hPalette As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  31.     Declare Function GetSystemPaletteEntries Lib "GDI" (ByVal hdc As Integer, ByVal wStartIndex As Integer, ByVal wNumEntries As Integer, lpPaletteEntries As PALETTEENTRY) As Integer
  32.     Declare Function RealizePalette Lib "User" (ByVal hdc As Integer) As Integer
  33. #End If
  34.  
  35.